<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>django.views.debug &mdash; Django 1.7.8.dev20150401230226 documentation</title>
    
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../',
        VERSION:     '1.7.8.dev20150401230226',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <link rel="top" title="Django 1.7.8.dev20150401230226 documentation" href="../../../index.html" />
    <link rel="up" title="django.views" href="../views.html" />



 
<script type="text/javascript" src="../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 1.7.8.dev20150401230226 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    <a href="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="_modules-django-views-debug">
            
  <h1>Source code for django.views.debug</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">unicode_literals</span>

<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">types</span>

<span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="p">(</span><span class="n">HttpResponse</span><span class="p">,</span> <span class="n">HttpResponseServerError</span><span class="p">,</span>
    <span class="n">HttpResponseNotFound</span><span class="p">,</span> <span class="n">HttpRequest</span><span class="p">,</span> <span class="n">build_request_repr</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">django.template</span> <span class="kn">import</span> <span class="n">Template</span><span class="p">,</span> <span class="n">Context</span><span class="p">,</span> <span class="n">TemplateDoesNotExist</span>
<span class="kn">from</span> <span class="nn">django.template.defaultfilters</span> <span class="kn">import</span> <span class="n">force_escape</span><span class="p">,</span> <span class="n">pprint</span>
<span class="kn">from</span> <span class="nn">django.utils.datastructures</span> <span class="kn">import</span> <span class="n">MultiValueDict</span>
<span class="kn">from</span> <span class="nn">django.utils.html</span> <span class="kn">import</span> <span class="n">escape</span>
<span class="kn">from</span> <span class="nn">django.utils.encoding</span> <span class="kn">import</span> <span class="n">force_bytes</span><span class="p">,</span> <span class="n">smart_text</span>
<span class="kn">from</span> <span class="nn">django.utils.module_loading</span> <span class="kn">import</span> <span class="n">import_string</span>
<span class="kn">from</span> <span class="nn">django.utils</span> <span class="kn">import</span> <span class="n">six</span>

<span class="n">HIDDEN_SETTINGS</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">&#39;API|TOKEN|KEY|SECRET|PASS|PROFANITIES_LIST|SIGNATURE&#39;</span><span class="p">)</span>

<span class="n">CLEANSED_SUBSTITUTE</span> <span class="o">=</span> <span class="s">&#39;********************&#39;</span>


<span class="k">def</span> <span class="nf">linebreak_iter</span><span class="p">(</span><span class="n">template_source</span><span class="p">):</span>
    <span class="k">yield</span> <span class="mi">0</span>
    <span class="n">p</span> <span class="o">=</span> <span class="n">template_source</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span><span class="p">)</span>
    <span class="k">while</span> <span class="n">p</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">:</span>
        <span class="k">yield</span> <span class="n">p</span> <span class="o">+</span> <span class="mi">1</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">template_source</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span><span class="p">,</span> <span class="n">p</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
    <span class="k">yield</span> <span class="nb">len</span><span class="p">(</span><span class="n">template_source</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>


<span class="k">class</span> <span class="nc">CallableSettingWrapper</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Object to wrap callable appearing in settings</span>

<span class="sd">    * Not to call in the debug page (#21345).</span>
<span class="sd">    * Not to break the debug page if the callable forbidding to set attributes (#23070).</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_setting</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_wrapped</span> <span class="o">=</span> <span class="n">callable_setting</span>

    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_wrapped</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">cleanse_setting</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Cleanse an individual setting key/value of sensitive content.</span>

<span class="sd">    If the value is a dictionary, recursively cleanse the keys in</span>
<span class="sd">    that dictionary.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">HIDDEN_SETTINGS</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">key</span><span class="p">):</span>
            <span class="n">cleansed</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">((</span><span class="n">k</span><span class="p">,</span> <span class="n">cleanse_setting</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">))</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="n">value</span>
    <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
        <span class="c"># If the key isn&#39;t regex-able, just return as-is.</span>
        <span class="n">cleansed</span> <span class="o">=</span> <span class="n">value</span>

    <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">cleansed</span><span class="p">):</span>
        <span class="c"># For fixing #21345 and #23070</span>
        <span class="n">cleansed</span> <span class="o">=</span> <span class="n">CallableSettingWrapper</span><span class="p">(</span><span class="n">cleansed</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">cleansed</span>


<span class="k">def</span> <span class="nf">get_safe_settings</span><span class="p">():</span>
    <span class="s">&quot;Returns a dictionary of the settings module, with sensitive settings blurred out.&quot;</span>
    <span class="n">settings_dict</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">settings</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">isupper</span><span class="p">():</span>
            <span class="n">settings_dict</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">cleanse_setting</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">settings</span><span class="p">,</span> <span class="n">k</span><span class="p">))</span>
    <span class="k">return</span> <span class="n">settings_dict</span>


<span class="k">def</span> <span class="nf">technical_500_response</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Create a technical server error response. The last three arguments are</span>
<span class="sd">    the values returned from sys.exc_info() and friends.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">reporter</span> <span class="o">=</span> <span class="n">ExceptionReporter</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">is_ajax</span><span class="p">():</span>
        <span class="n">text</span> <span class="o">=</span> <span class="n">reporter</span><span class="o">.</span><span class="n">get_traceback_text</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">HttpResponseServerError</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s">&#39;text/plain&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">html</span> <span class="o">=</span> <span class="n">reporter</span><span class="o">.</span><span class="n">get_traceback_html</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">HttpResponseServerError</span><span class="p">(</span><span class="n">html</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s">&#39;text/html&#39;</span><span class="p">)</span>

<span class="c"># Cache for the default exception reporter filter instance.</span>
<span class="n">default_exception_reporter_filter</span> <span class="o">=</span> <span class="bp">None</span>


<span class="k">def</span> <span class="nf">get_exception_reporter_filter</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="k">global</span> <span class="n">default_exception_reporter_filter</span>
    <span class="k">if</span> <span class="n">default_exception_reporter_filter</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="c"># Load the default filter for the first time and cache it.</span>
        <span class="n">default_exception_reporter_filter</span> <span class="o">=</span> <span class="n">import_string</span><span class="p">(</span>
            <span class="n">settings</span><span class="o">.</span><span class="n">DEFAULT_EXCEPTION_REPORTER_FILTER</span><span class="p">)()</span>
    <span class="k">if</span> <span class="n">request</span><span class="p">:</span>
        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s">&#39;exception_reporter_filter&#39;</span><span class="p">,</span> <span class="n">default_exception_reporter_filter</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">default_exception_reporter_filter</span>


<span class="k">class</span> <span class="nc">ExceptionReporterFilter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Base for all exception reporter filter classes. All overridable hooks</span>
<span class="sd">    contain lenient default behaviors.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">get_request_repr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">request</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">build_request_repr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">POST_override</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">get_post_parameters</span><span class="p">(</span><span class="n">request</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">get_post_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">request</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span>

    <span class="k">def</span> <span class="nf">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">tb_frame</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">six</span><span class="o">.</span><span class="n">iteritems</span><span class="p">(</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">))</span>


<div class="viewcode-block" id="SafeExceptionReporterFilter"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter">[docs]</a><span class="k">class</span> <span class="nc">SafeExceptionReporterFilter</span><span class="p">(</span><span class="n">ExceptionReporterFilter</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Use annotations made by the sensitive_post_parameters and</span>
<span class="sd">    sensitive_variables decorators to filter out sensitive information.</span>
<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.is_active"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.is_active">[docs]</a>    <span class="k">def</span> <span class="nf">is_active</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        This filter is to add safety in production environments (i.e. DEBUG</span>
<span class="sd">        is False). If DEBUG is True then your site is not safe anyway.</span>
<span class="sd">        This hook is provided as a convenience to easily activate or</span>
<span class="sd">        deactivate the filter on a per request basis.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">settings</span><span class="o">.</span><span class="n">DEBUG</span> <span class="ow">is</span> <span class="bp">False</span>
</div>
    <span class="k">def</span> <span class="nf">get_cleansed_multivaluedict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">multivaluedict</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the keys in a MultiValueDict marked as sensitive with stars.</span>
<span class="sd">        This mitigates leaking sensitive POST parameters if something like</span>
<span class="sd">        request.POST[&#39;nonexistent_key&#39;] throws an exception (#21098).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">sensitive_post_parameters</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s">&#39;sensitive_post_parameters&#39;</span><span class="p">,</span> <span class="p">[])</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
            <span class="n">multivaluedict</span> <span class="o">=</span> <span class="n">multivaluedict</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">multivaluedict</span><span class="p">:</span>
                    <span class="n">multivaluedict</span><span class="p">[</span><span class="n">param</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
        <span class="k">return</span> <span class="n">multivaluedict</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.get_post_parameters"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.get_post_parameters">[docs]</a>    <span class="k">def</span> <span class="nf">get_post_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the values of POST parameters marked as sensitive with</span>
<span class="sd">        stars (*********).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">request</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">sensitive_post_parameters</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s">&#39;sensitive_post_parameters&#39;</span><span class="p">,</span> <span class="p">[])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">sensitive_post_parameters</span> <span class="o">==</span> <span class="s">&#39;__ALL__&#39;</span><span class="p">:</span>
                    <span class="c"># Cleanse all parameters.</span>
                    <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">cleansed</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                        <span class="n">cleansed</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">return</span> <span class="n">cleansed</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="c"># Cleanse only the specified parameters.</span>
                    <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">cleansed</span><span class="p">:</span>
                            <span class="n">cleansed</span><span class="p">[</span><span class="n">param</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">return</span> <span class="n">cleansed</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span>
</div>
    <span class="k">def</span> <span class="nf">cleanse_special_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">HttpRequest</span><span class="p">):</span>
            <span class="c"># Cleanse the request&#39;s POST parameters.</span>
            <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_request_repr</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">MultiValueDict</span><span class="p">):</span>
            <span class="c"># Cleanse MultiValueDicts (request.POST is the one we usually care about)</span>
            <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_cleansed_multivaluedict</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">value</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.get_traceback_frame_variables"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables">[docs]</a>    <span class="k">def</span> <span class="nf">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">tb_frame</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the values of variables marked as sensitive with</span>
<span class="sd">        stars (*********).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c"># Loop through the frame&#39;s callers to see if the sensitive_variables</span>
        <span class="c"># decorator was used.</span>
        <span class="n">current_frame</span> <span class="o">=</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_back</span>
        <span class="n">sensitive_variables</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="k">while</span> <span class="n">current_frame</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">current_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span> <span class="o">==</span> <span class="s">&#39;sensitive_variables_wrapper&#39;</span>
                    <span class="ow">and</span> <span class="s">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">in</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">):</span>
                <span class="c"># The sensitive_variables decorator was used, so we take note</span>
                <span class="c"># of the sensitive variables&#39; names.</span>
                <span class="n">wrapper</span> <span class="o">=</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">[</span><span class="s">&#39;sensitive_variables_wrapper&#39;</span><span class="p">]</span>
                <span class="n">sensitive_variables</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">wrapper</span><span class="p">,</span> <span class="s">&#39;sensitive_variables&#39;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
                <span class="k">break</span>
            <span class="n">current_frame</span> <span class="o">=</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_back</span>

        <span class="n">cleansed</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_variables</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">sensitive_variables</span> <span class="o">==</span> <span class="s">&#39;__ALL__&#39;</span><span class="p">:</span>
                <span class="c"># Cleanse all variables</span>
                <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="c"># Cleanse specified variables</span>
                <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">sensitive_variables</span><span class="p">:</span>
                        <span class="n">value</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleanse_special_types</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
                    <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c"># Potentially cleanse the request and any MultiValueDicts if they</span>
            <span class="c"># are one of the frame variables.</span>
            <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleanse_special_types</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span> <span class="o">==</span> <span class="s">&#39;sensitive_variables_wrapper&#39;</span>
                <span class="ow">and</span> <span class="s">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">):</span>
            <span class="c"># For good measure, obfuscate the decorated function&#39;s arguments in</span>
            <span class="c"># the sensitive_variables decorator&#39;s frame, in case the variables</span>
            <span class="c"># associated with those arguments were meant to be obfuscated from</span>
            <span class="c"># the decorated function&#39;s frame.</span>
            <span class="n">cleansed</span><span class="p">[</span><span class="s">&#39;func_args&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
            <span class="n">cleansed</span><span class="p">[</span><span class="s">&#39;func_kwargs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>

        <span class="k">return</span> <span class="n">cleansed</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>

</div></div>
<span class="k">class</span> <span class="nc">ExceptionReporter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A class to organize and coordinate reporting on exceptions.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">,</span> <span class="n">is_email</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="n">request</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filter</span> <span class="o">=</span> <span class="n">get_exception_reporter_filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="o">=</span> <span class="n">exc_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span> <span class="o">=</span> <span class="n">exc_value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_email</span> <span class="o">=</span> <span class="n">is_email</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">template_info</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span> <span class="o">=</span> <span class="bp">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">loader_debug_info</span> <span class="o">=</span> <span class="bp">None</span>

        <span class="c"># Handle deprecated string exceptions</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="n">six</span><span class="o">.</span><span class="n">string_types</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span> <span class="o">=</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&#39;Deprecated String Exception: </span><span class="si">%r</span><span class="s">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">format_path_status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
            <span class="k">return</span> <span class="s">&quot;File does not exist&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
            <span class="k">return</span> <span class="s">&quot;Not a file&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">access</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">R_OK</span><span class="p">):</span>
            <span class="k">return</span> <span class="s">&quot;File is not readable&quot;</span>
        <span class="k">return</span> <span class="s">&quot;File exists&quot;</span>

    <span class="k">def</span> <span class="nf">get_traceback_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Return a dictionary containing traceback information.&quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="n">TemplateDoesNotExist</span><span class="p">):</span>
            <span class="kn">from</span> <span class="nn">django.template.loader</span> <span class="kn">import</span> <span class="n">template_source_loaders</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span> <span class="o">=</span> <span class="bp">True</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">loader_debug_info</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="c"># If the template_source_loaders haven&#39;t been populated yet, you need</span>
            <span class="c"># to provide an empty list for this for loop to not fail.</span>
            <span class="k">if</span> <span class="n">template_source_loaders</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">template_source_loaders</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">loader</span> <span class="ow">in</span> <span class="n">template_source_loaders</span><span class="p">:</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">source_list_func</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">get_template_sources</span>
                    <span class="c"># NOTE: This assumes exc_value is the name of the template that</span>
                    <span class="c"># the loader attempted to load.</span>
                    <span class="n">template_list</span> <span class="o">=</span> <span class="p">[{</span>
                        <span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="n">t</span><span class="p">,</span>
                        <span class="s">&#39;status&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_path_status</span><span class="p">(</span><span class="n">t</span><span class="p">),</span>
                    <span class="p">}</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">source_list_func</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">))]</span>
                <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                    <span class="n">template_list</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="n">loader_name</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">__module__</span> <span class="o">+</span> <span class="s">&#39;.&#39;</span> <span class="o">+</span> <span class="n">loader</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">loader_debug_info</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                    <span class="s">&#39;loader&#39;</span><span class="p">:</span> <span class="n">loader_name</span><span class="p">,</span>
                    <span class="s">&#39;templates&#39;</span><span class="p">:</span> <span class="n">template_list</span><span class="p">,</span>
                <span class="p">})</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">TEMPLATE_DEBUG</span> <span class="ow">and</span>
                <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s">&#39;django_template_source&#39;</span><span class="p">)):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">get_template_exception_info</span><span class="p">()</span>

        <span class="n">frames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_frames</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">frame</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">frames</span><span class="p">):</span>
            <span class="k">if</span> <span class="s">&#39;vars&#39;</span> <span class="ow">in</span> <span class="n">frame</span><span class="p">:</span>
                <span class="n">frame</span><span class="p">[</span><span class="s">&#39;vars&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[(</span><span class="n">k</span><span class="p">,</span> <span class="n">force_escape</span><span class="p">(</span><span class="n">pprint</span><span class="p">(</span><span class="n">v</span><span class="p">)))</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">frame</span><span class="p">[</span><span class="s">&#39;vars&#39;</span><span class="p">]]</span>
            <span class="n">frames</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">frame</span>

        <span class="n">unicode_hint</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="ne">UnicodeError</span><span class="p">):</span>
            <span class="n">start</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s">&#39;start&#39;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
            <span class="n">end</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s">&#39;end&#39;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">start</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">end</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">unicode_str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="n">unicode_hint</span> <span class="o">=</span> <span class="n">smart_text</span><span class="p">(</span><span class="n">unicode_str</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span><span class="nb">min</span><span class="p">(</span><span class="n">end</span> <span class="o">+</span> <span class="mi">5</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">unicode_str</span><span class="p">))],</span> <span class="s">&#39;ascii&#39;</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s">&#39;replace&#39;</span><span class="p">)</span>
        <span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">get_version</span>
        <span class="n">c</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s">&#39;is_email&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_email</span><span class="p">,</span>
            <span class="s">&#39;unicode_hint&#39;</span><span class="p">:</span> <span class="n">unicode_hint</span><span class="p">,</span>
            <span class="s">&#39;frames&#39;</span><span class="p">:</span> <span class="n">frames</span><span class="p">,</span>
            <span class="s">&#39;request&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span>
            <span class="s">&#39;filtered_POST&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="o">.</span><span class="n">get_post_parameters</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">),</span>
            <span class="s">&#39;settings&#39;</span><span class="p">:</span> <span class="n">get_safe_settings</span><span class="p">(),</span>
            <span class="s">&#39;sys_executable&#39;</span><span class="p">:</span> <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span>
            <span class="s">&#39;sys_version_info&#39;</span><span class="p">:</span> <span class="s">&#39;</span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">],</span>
            <span class="s">&#39;server_time&#39;</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span>
            <span class="s">&#39;django_version_info&#39;</span><span class="p">:</span> <span class="n">get_version</span><span class="p">(),</span>
            <span class="s">&#39;sys_path&#39;</span><span class="p">:</span> <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="p">,</span>
            <span class="s">&#39;template_info&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">template_info</span><span class="p">,</span>
            <span class="s">&#39;template_does_not_exist&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span><span class="p">,</span>
            <span class="s">&#39;loader_debug_info&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">loader_debug_info</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="c"># Check whether exception info is available</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s">&#39;exception_type&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="o">.</span><span class="n">__name__</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s">&#39;exception_value&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">smart_text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s">&#39;replace&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">frames</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s">&#39;lastframe&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">frames</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">c</span>

    <span class="k">def</span> <span class="nf">get_traceback_html</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="s">&quot;Return HTML version of debug 500 HTTP error page.&quot;</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">TECHNICAL_500_TEMPLATE</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;Technical 500 template&#39;</span><span class="p">)</span>
        <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_data</span><span class="p">(),</span> <span class="n">use_l10n</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_traceback_text</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="s">&quot;Return plain text version of debug 500 HTTP error page.&quot;</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">TECHNICAL_500_TEXT_TEMPLATE</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;Technical 500 template&#39;</span><span class="p">)</span>
        <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_data</span><span class="p">(),</span> <span class="n">autoescape</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">use_l10n</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_template_exception_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">origin</span><span class="p">,</span> <span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">)</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="o">.</span><span class="n">django_template_source</span>
        <span class="n">template_source</span> <span class="o">=</span> <span class="n">origin</span><span class="o">.</span><span class="n">reload</span><span class="p">()</span>
        <span class="n">context_lines</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="n">line</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">upto</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">source_lines</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">before</span> <span class="o">=</span> <span class="n">during</span> <span class="o">=</span> <span class="n">after</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="k">for</span> <span class="n">num</span><span class="p">,</span> <span class="nb">next</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">linebreak_iter</span><span class="p">(</span><span class="n">template_source</span><span class="p">)):</span>
            <span class="k">if</span> <span class="n">start</span> <span class="o">&gt;=</span> <span class="n">upto</span> <span class="ow">and</span> <span class="n">end</span> <span class="o">&lt;=</span> <span class="nb">next</span><span class="p">:</span>
                <span class="n">line</span> <span class="o">=</span> <span class="n">num</span>
                <span class="n">before</span> <span class="o">=</span> <span class="n">escape</span><span class="p">(</span><span class="n">template_source</span><span class="p">[</span><span class="n">upto</span><span class="p">:</span><span class="n">start</span><span class="p">])</span>
                <span class="n">during</span> <span class="o">=</span> <span class="n">escape</span><span class="p">(</span><span class="n">template_source</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">])</span>
                <span class="n">after</span> <span class="o">=</span> <span class="n">escape</span><span class="p">(</span><span class="n">template_source</span><span class="p">[</span><span class="n">end</span><span class="p">:</span><span class="nb">next</span><span class="p">])</span>
            <span class="n">source_lines</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">num</span><span class="p">,</span> <span class="n">escape</span><span class="p">(</span><span class="n">template_source</span><span class="p">[</span><span class="n">upto</span><span class="p">:</span><span class="nb">next</span><span class="p">])))</span>
            <span class="n">upto</span> <span class="o">=</span> <span class="nb">next</span>
        <span class="n">total</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">source_lines</span><span class="p">)</span>

        <span class="n">top</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">line</span> <span class="o">-</span> <span class="n">context_lines</span><span class="p">)</span>
        <span class="n">bottom</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">total</span><span class="p">,</span> <span class="n">line</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">context_lines</span><span class="p">)</span>

        <span class="c"># In some rare cases, exc_value.args might be empty.</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
            <span class="n">message</span> <span class="o">=</span> <span class="s">&#39;(Could not get exception message)&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">template_info</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s">&#39;message&#39;</span><span class="p">:</span> <span class="n">message</span><span class="p">,</span>
            <span class="s">&#39;source_lines&#39;</span><span class="p">:</span> <span class="n">source_lines</span><span class="p">[</span><span class="n">top</span><span class="p">:</span><span class="n">bottom</span><span class="p">],</span>
            <span class="s">&#39;before&#39;</span><span class="p">:</span> <span class="n">before</span><span class="p">,</span>
            <span class="s">&#39;during&#39;</span><span class="p">:</span> <span class="n">during</span><span class="p">,</span>
            <span class="s">&#39;after&#39;</span><span class="p">:</span> <span class="n">after</span><span class="p">,</span>
            <span class="s">&#39;top&#39;</span><span class="p">:</span> <span class="n">top</span><span class="p">,</span>
            <span class="s">&#39;bottom&#39;</span><span class="p">:</span> <span class="n">bottom</span><span class="p">,</span>
            <span class="s">&#39;total&#39;</span><span class="p">:</span> <span class="n">total</span><span class="p">,</span>
            <span class="s">&#39;line&#39;</span><span class="p">:</span> <span class="n">line</span><span class="p">,</span>
            <span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="n">origin</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">_get_lines_from_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="n">context_lines</span><span class="p">,</span> <span class="n">loader</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">module_name</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns context_lines before and after lineno from file.</span>
<span class="sd">        Returns (pre_context_lineno, pre_context, context_line, post_context).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">source</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="k">if</span> <span class="n">loader</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">loader</span><span class="p">,</span> <span class="s">&quot;get_source&quot;</span><span class="p">):</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">source</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">get_source</span><span class="p">(</span><span class="n">module_name</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
                <span class="k">pass</span>
            <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">source</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
                    <span class="n">source</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
            <span class="k">except</span> <span class="p">(</span><span class="ne">OSError</span><span class="p">,</span> <span class="ne">IOError</span><span class="p">):</span>
                <span class="k">pass</span>
        <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">None</span><span class="p">,</span> <span class="p">[],</span> <span class="bp">None</span><span class="p">,</span> <span class="p">[]</span>

        <span class="c"># If we just read the source from a file, or if the loader did not</span>
        <span class="c"># apply tokenize.detect_encoding to decode the source into a Unicode</span>
        <span class="c"># string, then we should do that ourselves.</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">six</span><span class="o">.</span><span class="n">binary_type</span><span class="p">):</span>
            <span class="n">encoding</span> <span class="o">=</span> <span class="s">&#39;ascii&#39;</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">source</span><span class="p">[:</span><span class="mi">2</span><span class="p">]:</span>
                <span class="c"># File coding may be specified. Match pattern from PEP-263</span>
                <span class="c"># (http://www.python.org/dev/peps/pep-0263/)</span>
                <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">br</span><span class="s">&#39;coding[:=]\s*([-\w.]+)&#39;</span><span class="p">,</span> <span class="n">line</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">match</span><span class="p">:</span>
                    <span class="n">encoding</span> <span class="o">=</span> <span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s">&#39;ascii&#39;</span><span class="p">)</span>
                    <span class="k">break</span>
            <span class="n">source</span> <span class="o">=</span> <span class="p">[</span><span class="n">six</span><span class="o">.</span><span class="n">text_type</span><span class="p">(</span><span class="n">sline</span><span class="p">,</span> <span class="n">encoding</span><span class="p">,</span> <span class="s">&#39;replace&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">sline</span> <span class="ow">in</span> <span class="n">source</span><span class="p">]</span>

        <span class="n">lower_bound</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">lineno</span> <span class="o">-</span> <span class="n">context_lines</span><span class="p">)</span>
        <span class="n">upper_bound</span> <span class="o">=</span> <span class="n">lineno</span> <span class="o">+</span> <span class="n">context_lines</span>

        <span class="n">pre_context</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lower_bound</span><span class="p">:</span><span class="n">lineno</span><span class="p">]</span>
        <span class="n">context_line</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lineno</span><span class="p">]</span>
        <span class="n">post_context</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:</span><span class="n">upper_bound</span><span class="p">]</span>

        <span class="k">return</span> <span class="n">lower_bound</span><span class="p">,</span> <span class="n">pre_context</span><span class="p">,</span> <span class="n">context_line</span><span class="p">,</span> <span class="n">post_context</span>

    <span class="k">def</span> <span class="nf">get_traceback_frames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">frames</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">tb</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tb</span>
        <span class="k">while</span> <span class="n">tb</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="c"># Support for __traceback_hide__ which is used by a few libraries</span>
            <span class="c"># to hide internal frames.</span>
            <span class="k">if</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;__traceback_hide__&#39;</span><span class="p">):</span>
                <span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span>
                <span class="k">continue</span>
            <span class="n">filename</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_filename</span>
            <span class="n">function</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span>
            <span class="n">lineno</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_lineno</span> <span class="o">-</span> <span class="mi">1</span>
            <span class="n">loader</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_globals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;__loader__&#39;</span><span class="p">)</span>
            <span class="n">module_name</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_globals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;__name__&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="s">&#39;&#39;</span>
            <span class="n">pre_context_lineno</span><span class="p">,</span> <span class="n">pre_context</span><span class="p">,</span> <span class="n">context_line</span><span class="p">,</span> <span class="n">post_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_lines_from_file</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="n">loader</span><span class="p">,</span> <span class="n">module_name</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">pre_context_lineno</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
                <span class="n">frames</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                    <span class="s">&#39;tb&#39;</span><span class="p">:</span> <span class="n">tb</span><span class="p">,</span>
                    <span class="s">&#39;type&#39;</span><span class="p">:</span> <span class="s">&#39;django&#39;</span> <span class="k">if</span> <span class="n">module_name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">&#39;django.&#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s">&#39;user&#39;</span><span class="p">,</span>
                    <span class="s">&#39;filename&#39;</span><span class="p">:</span> <span class="n">filename</span><span class="p">,</span>
                    <span class="s">&#39;function&#39;</span><span class="p">:</span> <span class="n">function</span><span class="p">,</span>
                    <span class="s">&#39;lineno&#39;</span><span class="p">:</span> <span class="n">lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
                    <span class="s">&#39;vars&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="o">.</span><span class="n">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="p">),</span>
                    <span class="s">&#39;id&#39;</span><span class="p">:</span> <span class="nb">id</span><span class="p">(</span><span class="n">tb</span><span class="p">),</span>
                    <span class="s">&#39;pre_context&#39;</span><span class="p">:</span> <span class="n">pre_context</span><span class="p">,</span>
                    <span class="s">&#39;context_line&#39;</span><span class="p">:</span> <span class="n">context_line</span><span class="p">,</span>
                    <span class="s">&#39;post_context&#39;</span><span class="p">:</span> <span class="n">post_context</span><span class="p">,</span>
                    <span class="s">&#39;pre_context_lineno&#39;</span><span class="p">:</span> <span class="n">pre_context_lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
                <span class="p">})</span>
            <span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span>

        <span class="k">return</span> <span class="n">frames</span>

    <span class="k">def</span> <span class="nf">format_exception</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the same data as from traceback.format_exception.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">traceback</span>
        <span class="n">frames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_frames</span><span class="p">()</span>
        <span class="n">tb</span> <span class="o">=</span> <span class="p">[(</span><span class="n">f</span><span class="p">[</span><span class="s">&#39;filename&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s">&#39;lineno&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s">&#39;function&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s">&#39;context_line&#39;</span><span class="p">])</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">frames</span><span class="p">]</span>
        <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Traceback (most recent call last):</span><span class="se">\n</span><span class="s">&#39;</span><span class="p">]</span>
        <span class="nb">list</span> <span class="o">+=</span> <span class="n">traceback</span><span class="o">.</span><span class="n">format_list</span><span class="p">(</span><span class="n">tb</span><span class="p">)</span>
        <span class="nb">list</span> <span class="o">+=</span> <span class="n">traceback</span><span class="o">.</span><span class="n">format_exception_only</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">list</span>


<span class="k">def</span> <span class="nf">technical_404_response</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exception</span><span class="p">):</span>
    <span class="s">&quot;Create a technical 404 error response. The exception should be the Http404.&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">error_url</span> <span class="o">=</span> <span class="n">exception</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s">&#39;path&#39;</span><span class="p">]</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">IndexError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
        <span class="n">error_url</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">path_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>  <span class="c"># Trim leading slash</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">tried</span> <span class="o">=</span> <span class="n">exception</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s">&#39;tried&#39;</span><span class="p">]</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">IndexError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
        <span class="n">tried</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">tried</span>                           <span class="c"># empty URLconf</span>
            <span class="ow">or</span> <span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">path</span> <span class="o">==</span> <span class="s">&#39;/&#39;</span>
                <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">tried</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>             <span class="c"># default URLconf</span>
                <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">==</span> <span class="mi">1</span>
                <span class="ow">and</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="s">&#39;app_name&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="s">&#39;namespace&#39;</span><span class="p">,</span> <span class="s">&#39;&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;admin&#39;</span><span class="p">)):</span>
            <span class="k">return</span> <span class="n">default_urlconf</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>

    <span class="n">urlconf</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s">&#39;urlconf&#39;</span><span class="p">,</span> <span class="n">settings</span><span class="o">.</span><span class="n">ROOT_URLCONF</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">urlconf</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ModuleType</span><span class="p">):</span>
        <span class="n">urlconf</span> <span class="o">=</span> <span class="n">urlconf</span><span class="o">.</span><span class="n">__name__</span>

    <span class="n">t</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">TECHNICAL_404_TEMPLATE</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;Technical 404 template&#39;</span><span class="p">)</span>
    <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">({</span>
        <span class="s">&#39;urlconf&#39;</span><span class="p">:</span> <span class="n">urlconf</span><span class="p">,</span>
        <span class="s">&#39;root_urlconf&#39;</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">ROOT_URLCONF</span><span class="p">,</span>
        <span class="s">&#39;request_path&#39;</span><span class="p">:</span> <span class="n">error_url</span><span class="p">,</span>
        <span class="s">&#39;urlpatterns&#39;</span><span class="p">:</span> <span class="n">tried</span><span class="p">,</span>
        <span class="s">&#39;reason&#39;</span><span class="p">:</span> <span class="n">force_bytes</span><span class="p">(</span><span class="n">exception</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s">&#39;replace&#39;</span><span class="p">),</span>
        <span class="s">&#39;request&#39;</span><span class="p">:</span> <span class="n">request</span><span class="p">,</span>
        <span class="s">&#39;settings&#39;</span><span class="p">:</span> <span class="n">get_safe_settings</span><span class="p">(),</span>
    <span class="p">})</span>
    <span class="k">return</span> <span class="n">HttpResponseNotFound</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">),</span> <span class="n">content_type</span><span class="o">=</span><span class="s">&#39;text/html&#39;</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">default_urlconf</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="s">&quot;Create an empty URLconf 404 error response.&quot;</span>
    <span class="n">t</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">DEFAULT_URLCONF_TEMPLATE</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;Default URLconf template&#39;</span><span class="p">)</span>
    <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">({})</span>
    <span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">),</span> <span class="n">content_type</span><span class="o">=</span><span class="s">&#39;text/html&#39;</span><span class="p">)</span>

<span class="c">#</span>
<span class="c"># Templates are embedded in the file so that we know the error handler will</span>
<span class="c"># always work even if the template loader is broken.</span>
<span class="c">#</span>

<span class="n">TECHNICAL_500_TEMPLATE</span> <span class="o">=</span> <span class="s">&quot;&quot;&quot;</span>
<span class="s">&lt;!DOCTYPE html&gt;</span>
<span class="s">&lt;html lang=&quot;en&quot;&gt;</span>
<span class="s">&lt;head&gt;</span>
<span class="s">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;</span>
<span class="s">  &lt;title&gt;{</span><span class="si">% i</span><span class="s">f exception_type %}{{ exception_type }}{</span><span class="si">% e</span><span class="s">lse %}Report{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info|escape }}{</span><span class="si">% e</span><span class="s">ndif %}&lt;/title&gt;</span>
<span class="s">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="s">    html * { padding:0; margin:0; }</span>
<span class="s">    body * { padding:10px 20px; }</span>
<span class="s">    body * * { padding:0; }</span>
<span class="s">    body { font:small sans-serif; }</span>
<span class="s">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="s">    h1 { font-weight:normal; }</span>
<span class="s">    h2 { margin-bottom:.8em; }</span>
<span class="s">    h2 span { font-size:80%; color:#666; font-weight:normal; }</span>
<span class="s">    h3 { margin:1em 0 .5em 0; }</span>
<span class="s">    h4 { margin:0 0 .5em 0; font-weight: normal; }</span>
<span class="s">    code, pre { font-size: 100%; white-space: pre-wrap; }</span>
<span class="s">    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }</span>
<span class="s">    tbody td, tbody th { vertical-align:top; padding:2px 3px; }</span>
<span class="s">    thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }</span>
<span class="s">    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="s">    table.vars { margin:5px 0 2px 40px; }</span>
<span class="s">    table.vars td, table.req td { font-family:monospace; }</span>
<span class="s">    table td.code { width:100%; }</span>
<span class="s">    table td.code pre { overflow:hidden; }</span>
<span class="s">    table.source th { color:#666; }</span>
<span class="s">    table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }</span>
<span class="s">    ul.traceback { list-style-type:none; color: #222; }</span>
<span class="s">    ul.traceback li.frame { padding-bottom:1em; color:#666; }</span>
<span class="s">    ul.traceback li.user { background-color:#e0e0e0; color:#000 }</span>
<span class="s">    div.context { padding:10px 0; overflow:hidden; }</span>
<span class="s">    div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }</span>
<span class="s">    div.context ol li { font-family:monospace; white-space:pre; color:#777; cursor:pointer; }</span>
<span class="s">    div.context ol li pre { display:inline; }</span>
<span class="s">    div.context ol.context-line li { color:#505050; background-color:#dfdfdf; }</span>
<span class="s">    div.context ol.context-line li span { position:absolute; right:32px; }</span>
<span class="s">    .user div.context ol.context-line li { background-color:#bbb; color:#000; }</span>
<span class="s">    .user div.context ol li { color:#666; }</span>
<span class="s">    div.commands { margin-left: 40px; }</span>
<span class="s">    div.commands a { color:#555; text-decoration:none; }</span>
<span class="s">    .user div.commands a { color: black; }</span>
<span class="s">    #summary { background: #ffc; }</span>
<span class="s">    #summary h2 { font-weight: normal; color: #666; }</span>
<span class="s">    #explanation { background:#eee; }</span>
<span class="s">    #template, #template-not-exist { background:#f6f6f6; }</span>
<span class="s">    #template-not-exist ul { margin: 0 0 0 20px; }</span>
<span class="s">    #unicode-hint { background:#eee; }</span>
<span class="s">    #traceback { background:#eee; }</span>
<span class="s">    #requestinfo { background:#f6f6f6; padding-left:120px; }</span>
<span class="s">    #summary table { border:none; background:transparent; }</span>
<span class="s">    #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }</span>
<span class="s">    #requestinfo h3 { margin-bottom:-1em; }</span>
<span class="s">    .error { background: #ffc; }</span>
<span class="s">    .specific { color:#cc3300; font-weight:bold; }</span>
<span class="s">    h2 span.commands { font-size:.7em;}</span>
<span class="s">    span.commands a:link {color:#5E5694;}</span>
<span class="s">    pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; }</span>
<span class="s">  &lt;/style&gt;</span>
<span class="s">  {</span><span class="si">% i</span><span class="s">f not is_email %}</span>
<span class="s">  &lt;script type=&quot;text/javascript&quot;&gt;</span>
<span class="s">  //&lt;!--</span>
<span class="s">    function getElementsByClassName(oElm, strTagName, strClassName){</span>
<span class="s">        // Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com</span>
<span class="s">        var arrElements = (strTagName == &quot;*&quot; &amp;&amp; document.all)? document.all :</span>
<span class="s">        oElm.getElementsByTagName(strTagName);</span>
<span class="s">        var arrReturnElements = new Array();</span>
<span class="s">        strClassName = strClassName.replace(/\-/g, &quot;</span><span class="se">\\</span><span class="s">-&quot;);</span>
<span class="s">        var oRegExp = new RegExp(&quot;(^|</span><span class="se">\\</span><span class="s">s)&quot; + strClassName + &quot;(</span><span class="se">\\</span><span class="s">s|$)&quot;);</span>
<span class="s">        var oElement;</span>
<span class="s">        for(var i=0; i&lt;arrElements.length; i++){</span>
<span class="s">            oElement = arrElements[i];</span>
<span class="s">            if(oRegExp.test(oElement.className)){</span>
<span class="s">                arrReturnElements.push(oElement);</span>
<span class="s">            }</span>
<span class="s">        }</span>
<span class="s">        return (arrReturnElements)</span>
<span class="s">    }</span>
<span class="s">    function hideAll(elems) {</span>
<span class="s">      for (var e = 0; e &lt; elems.length; e++) {</span>
<span class="s">        elems[e].style.display = &#39;none&#39;;</span>
<span class="s">      }</span>
<span class="s">    }</span>
<span class="s">    window.onload = function() {</span>
<span class="s">      hideAll(getElementsByClassName(document, &#39;table&#39;, &#39;vars&#39;));</span>
<span class="s">      hideAll(getElementsByClassName(document, &#39;ol&#39;, &#39;pre-context&#39;));</span>
<span class="s">      hideAll(getElementsByClassName(document, &#39;ol&#39;, &#39;post-context&#39;));</span>
<span class="s">      hideAll(getElementsByClassName(document, &#39;div&#39;, &#39;pastebin&#39;));</span>
<span class="s">    }</span>
<span class="s">    function toggle() {</span>
<span class="s">      for (var i = 0; i &lt; arguments.length; i++) {</span>
<span class="s">        var e = document.getElementById(arguments[i]);</span>
<span class="s">        if (e) {</span>
<span class="s">          e.style.display = e.style.display == &#39;none&#39; ? &#39;block&#39;: &#39;none&#39;;</span>
<span class="s">        }</span>
<span class="s">      }</span>
<span class="s">      return false;</span>
<span class="s">    }</span>
<span class="s">    function varToggle(link, id) {</span>
<span class="s">      toggle(&#39;v&#39; + id);</span>
<span class="s">      var s = link.getElementsByTagName(&#39;span&#39;)[0];</span>
<span class="s">      var uarr = String.fromCharCode(0x25b6);</span>
<span class="s">      var darr = String.fromCharCode(0x25bc);</span>
<span class="s">      s.innerHTML = s.innerHTML == uarr ? darr : uarr;</span>
<span class="s">      return false;</span>
<span class="s">    }</span>
<span class="s">    function switchPastebinFriendly(link) {</span>
<span class="s">      s1 = &quot;Switch to copy-and-paste view&quot;;</span>
<span class="s">      s2 = &quot;Switch back to interactive view&quot;;</span>
<span class="s">      link.innerHTML = link.innerHTML == s1 ? s2: s1;</span>
<span class="s">      toggle(&#39;browserTraceback&#39;, &#39;pastebinTraceback&#39;);</span>
<span class="s">      return false;</span>
<span class="s">    }</span>
<span class="s">    //--&gt;</span>
<span class="s">  &lt;/script&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">&lt;/head&gt;</span>
<span class="s">&lt;body&gt;</span>
<span class="s">&lt;div id=&quot;summary&quot;&gt;</span>
<span class="s">  &lt;h1&gt;{</span><span class="si">% i</span><span class="s">f exception_type %}{{ exception_type }}{</span><span class="si">% e</span><span class="s">lse %}Report{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info|escape }}{</span><span class="si">% e</span><span class="s">ndif %}&lt;/h1&gt;</span>
<span class="s">  &lt;pre class=&quot;exception_value&quot;&gt;{</span><span class="si">% i</span><span class="s">f exception_value %}{{ exception_value|force_escape }}{</span><span class="si">% e</span><span class="s">lse %}No exception message supplied{</span><span class="si">% e</span><span class="s">ndif %}&lt;/pre&gt;</span>
<span class="s">  &lt;table class=&quot;meta&quot;&gt;</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f request %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Request Method:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ request.META.REQUEST_METHOD }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Request URL:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ request.build_absolute_uri|escape }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Django Version:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ django_version_info }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f exception_type %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Exception Type:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ exception_type }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f exception_type and exception_value %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Exception Value:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;&lt;pre&gt;{{ exception_value|force_escape }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f lastframe %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Exception Location:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Python Executable:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ sys_executable|escape }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Python Version:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ sys_version_info }}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Python Path:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;&lt;pre&gt;{{ sys_path|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">    &lt;tr&gt;</span>
<span class="s">      &lt;th&gt;Server time:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{server_time|date:&quot;r&quot;}}&lt;/td&gt;</span>
<span class="s">    &lt;/tr&gt;</span>
<span class="s">  &lt;/table&gt;</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f unicode_hint %}</span>
<span class="s">&lt;div id=&quot;unicode-hint&quot;&gt;</span>
<span class="s">    &lt;h2&gt;Unicode error hint&lt;/h2&gt;</span>
<span class="s">    &lt;p&gt;The string that could not be encoded/decoded was: &lt;strong&gt;{{ unicode_hint|force_escape }}&lt;/strong&gt;&lt;/p&gt;</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f template_does_not_exist %}</span>
<span class="s">&lt;div id=&quot;template-not-exist&quot;&gt;</span>
<span class="s">    &lt;h2&gt;Template-loader postmortem&lt;/h2&gt;</span>
<span class="s">    {</span><span class="si">% i</span><span class="s">f loader_debug_info %}</span>
<span class="s">        &lt;p&gt;Django tried loading these templates, in this order:&lt;/p&gt;</span>
<span class="s">        &lt;ul&gt;</span>
<span class="s">        {</span><span class="si">% f</span><span class="s">or loader in loader_debug_info %}</span>
<span class="s">            &lt;li&gt;Using loader &lt;code&gt;{{ loader.loader }}&lt;/code&gt;:</span>
<span class="s">                &lt;ul&gt;</span>
<span class="s">                {</span><span class="si">% f</span><span class="s">or t in loader.templates %}&lt;li&gt;&lt;code&gt;{{ t.name }}&lt;/code&gt; ({{ t.status }})&lt;/li&gt;{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">                &lt;/ul&gt;</span>
<span class="s">            &lt;/li&gt;</span>
<span class="s">        {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">        &lt;/ul&gt;</span>
<span class="s">    {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">        &lt;p&gt;Django couldn&#39;t find any templates because your &lt;code&gt;TEMPLATE_LOADERS&lt;/code&gt; setting is empty!&lt;/p&gt;</span>
<span class="s">    {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f template_info %}</span>
<span class="s">&lt;div id=&quot;template&quot;&gt;</span>
<span class="s">   &lt;h2&gt;Error during template rendering&lt;/h2&gt;</span>
<span class="s">   &lt;p&gt;In template &lt;code&gt;{{ template_info.name }}&lt;/code&gt;, error at line &lt;strong&gt;{{ template_info.line }}&lt;/strong&gt;&lt;/p&gt;</span>
<span class="s">   &lt;h3&gt;{{ template_info.message }}&lt;/h3&gt;</span>
<span class="s">   &lt;table class=&quot;source{</span><span class="si">% i</span><span class="s">f template_info.top %} cut-top{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">fnotequal template_info.bottom template_info.total %} cut-bottom{</span><span class="si">% e</span><span class="s">ndifnotequal %}&quot;&gt;</span>
<span class="s">   {</span><span class="si">% f</span><span class="s">or source_line in template_info.source_lines %}</span>
<span class="s">   {</span><span class="si">% i</span><span class="s">fequal source_line.0 template_info.line %}</span>
<span class="s">       &lt;tr class=&quot;error&quot;&gt;&lt;th&gt;{{ source_line.0 }}&lt;/th&gt;</span>
<span class="s">       &lt;td&gt;{{ template_info.before }}&lt;span class=&quot;specific&quot;&gt;{{ template_info.during }}&lt;/span&gt;{{ template_info.after }}&lt;/td&gt;&lt;/tr&gt;</span>
<span class="s">   {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">      &lt;tr&gt;&lt;th&gt;{{ source_line.0 }}&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ source_line.1 }}&lt;/td&gt;&lt;/tr&gt;</span>
<span class="s">   {</span><span class="si">% e</span><span class="s">ndifequal %}</span>
<span class="s">   {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">   &lt;/table&gt;</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f frames %}</span>
<span class="s">&lt;div id=&quot;traceback&quot;&gt;</span>
<span class="s">  &lt;h2&gt;Traceback &lt;span class=&quot;commands&quot;&gt;{</span><span class="si">% i</span><span class="s">f not is_email %}&lt;a href=&quot;#&quot; onclick=&quot;return switchPastebinFriendly(this);&quot;&gt;Switch to copy-and-paste view&lt;/a&gt;&lt;/span&gt;{</span><span class="si">% e</span><span class="s">ndif %}&lt;/h2&gt;</span>
<span class="s">  {% autoescape off %}</span>
<span class="s">  &lt;div id=&quot;browserTraceback&quot;&gt;</span>
<span class="s">    &lt;ul class=&quot;traceback&quot;&gt;</span>
<span class="s">      {</span><span class="si">% f</span><span class="s">or frame in frames %}</span>
<span class="s">        &lt;li class=&quot;frame {{ frame.type }}&quot;&gt;</span>
<span class="s">          &lt;code&gt;{{ frame.filename|escape }}&lt;/code&gt; in &lt;code&gt;{{ frame.function|escape }}&lt;/code&gt;</span>

<span class="s">          {</span><span class="si">% i</span><span class="s">f frame.context_line %}</span>
<span class="s">            &lt;div class=&quot;context&quot; id=&quot;c{{ frame.id }}&quot;&gt;</span>
<span class="s">              {</span><span class="si">% i</span><span class="s">f frame.pre_context and not is_email %}</span>
<span class="s">                &lt;ol start=&quot;{{ frame.pre_context_lineno }}&quot; class=&quot;pre-context&quot; id=&quot;pre{{ frame.id }}&quot;&gt;{</span><span class="si">% f</span><span class="s">or line in frame.pre_context %}&lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;{{ line|escape }}&lt;/pre&gt;&lt;/li&gt;{</span><span class="si">% e</span><span class="s">ndfor %}&lt;/ol&gt;</span>
<span class="s">              {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">              &lt;ol start=&quot;{{ frame.lineno }}&quot; class=&quot;context-line&quot;&gt;&lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;{{ frame.context_line|escape }}&lt;/pre&gt;{</span><span class="si">% i</span><span class="s">f not is_email %} &lt;span&gt;...&lt;/span&gt;{</span><span class="si">% e</span><span class="s">ndif %}&lt;/li&gt;&lt;/ol&gt;</span>
<span class="s">              {</span><span class="si">% i</span><span class="s">f frame.post_context and not is_email  %}</span>
<span class="s">                &lt;ol start=&#39;{{ frame.lineno|add:&quot;1&quot; }}&#39; class=&quot;post-context&quot; id=&quot;post{{ frame.id }}&quot;&gt;{</span><span class="si">% f</span><span class="s">or line in frame.post_context %}&lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;{{ line|escape }}&lt;/pre&gt;&lt;/li&gt;{</span><span class="si">% e</span><span class="s">ndfor %}&lt;/ol&gt;</span>
<span class="s">              {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">            &lt;/div&gt;</span>
<span class="s">          {</span><span class="si">% e</span><span class="s">ndif %}</span>

<span class="s">          {</span><span class="si">% i</span><span class="s">f frame.vars %}</span>
<span class="s">            &lt;div class=&quot;commands&quot;&gt;</span>
<span class="s">                {</span><span class="si">% i</span><span class="s">f is_email %}</span>
<span class="s">                    &lt;h2&gt;Local Vars&lt;/h2&gt;</span>
<span class="s">                {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">                    &lt;a href=&quot;#&quot; onclick=&quot;return varToggle(this, &#39;{{ frame.id }}&#39;)&quot;&gt;&lt;span&gt;&amp;#x25b6;&lt;/span&gt; Local vars&lt;/a&gt;</span>
<span class="s">                {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">            &lt;/div&gt;</span>
<span class="s">            &lt;table class=&quot;vars&quot; id=&quot;v{{ frame.id }}&quot;&gt;</span>
<span class="s">              &lt;thead&gt;</span>
<span class="s">                &lt;tr&gt;</span>
<span class="s">                  &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">                  &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">                &lt;/tr&gt;</span>
<span class="s">              &lt;/thead&gt;</span>
<span class="s">              &lt;tbody&gt;</span>
<span class="s">                {</span><span class="si">% f</span><span class="s">or var in frame.vars|dictsort:&quot;0&quot; %}</span>
<span class="s">                  &lt;tr&gt;</span>
<span class="s">                    &lt;td&gt;{{ var.0|force_escape }}&lt;/td&gt;</span>
<span class="s">                    &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1 }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">                  &lt;/tr&gt;</span>
<span class="s">                {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">              &lt;/tbody&gt;</span>
<span class="s">            &lt;/table&gt;</span>
<span class="s">          {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">        &lt;/li&gt;</span>
<span class="s">      {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">    &lt;/ul&gt;</span>
<span class="s">  &lt;/div&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndautoescape %}</span>
<span class="s">  &lt;form action=&quot;http://dpaste.com/&quot; name=&quot;pasteform&quot; id=&quot;pasteform&quot; method=&quot;post&quot;&gt;</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f not is_email %}</span>
<span class="s">  &lt;div id=&quot;pastebinTraceback&quot; class=&quot;pastebin&quot;&gt;</span>
<span class="s">    &lt;input type=&quot;hidden&quot; name=&quot;language&quot; value=&quot;PythonConsole&quot;&gt;</span>
<span class="s">    &lt;input type=&quot;hidden&quot; name=&quot;title&quot; value=&quot;{{ exception_type|escape }}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info|escape }}{</span><span class="si">% e</span><span class="s">ndif %}&quot;&gt;</span>
<span class="s">    &lt;input type=&quot;hidden&quot; name=&quot;source&quot; value=&quot;Django Dpaste Agent&quot;&gt;</span>
<span class="s">    &lt;input type=&quot;hidden&quot; name=&quot;poster&quot; value=&quot;Django&quot;&gt;</span>
<span class="s">    &lt;textarea name=&quot;content&quot; id=&quot;traceback_area&quot; cols=&quot;140&quot; rows=&quot;25&quot;&gt;</span>
<span class="s">Environment:</span>

<span class="s">{</span><span class="si">% i</span><span class="s">f request %}</span>
<span class="s">Request Method: {{ request.META.REQUEST_METHOD }}</span>
<span class="s">Request URL: {{ request.build_absolute_uri|escape }}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">Django Version: {{ django_version_info }}</span>
<span class="s">Python Version: {{ sys_version_info }}</span>
<span class="s">Installed Applications:</span>
<span class="s">{{ settings.INSTALLED_APPS|pprint }}</span>
<span class="s">Installed Middleware:</span>
<span class="s">{{ settings.MIDDLEWARE_CLASSES|pprint }}</span>

<span class="s">{</span><span class="si">% i</span><span class="s">f template_does_not_exist %}Template Loader Error:</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f loader_debug_info %}Django tried loading these templates, in this order:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or loader in loader_debug_info %}Using loader {{ loader.loader }}:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or t in loader.templates %}{{ t.name }} ({{ t.status }})</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndfor %}{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}Django couldn&#39;t find any templates because your TEMPLATE_LOADERS setting is empty!</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">f template_info %}</span>
<span class="s">Template error:</span>
<span class="s">In template {{ template_info.name }}, error at line {{ template_info.line }}</span>
<span class="s">   {{ template_info.message }}{</span><span class="si">% f</span><span class="s">or source_line in template_info.source_lines %}{</span><span class="si">% i</span><span class="s">fequal source_line.0 template_info.line %}</span>
<span class="s">   {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">   {{ source_line.0 }} : {{ source_line.1 }}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndifequal %}{</span><span class="si">% e</span><span class="s">ndfor %}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">Traceback:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or frame in frames %}File &quot;{{ frame.filename|escape }}&quot; in {{ frame.function|escape }}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f frame.context_line %}  {{ frame.lineno }}. {{ frame.context_line|escape }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">Exception Type: {{ exception_type|escape }}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info|escape }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">Exception Value: {{ exception_value|force_escape }}</span>
<span class="s">&lt;/textarea&gt;</span>
<span class="s">  &lt;br&gt;&lt;br&gt;</span>
<span class="s">  &lt;input type=&quot;submit&quot; value=&quot;Share this traceback on a public Web site&quot;&gt;</span>
<span class="s">  &lt;/div&gt;</span>
<span class="s">&lt;/form&gt;</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>

<span class="s">&lt;div id=&quot;requestinfo&quot;&gt;</span>
<span class="s">  &lt;h2&gt;Request information&lt;/h2&gt;</span>

<span class="s">{</span><span class="si">% i</span><span class="s">f request %}</span>
<span class="s">  &lt;h3 id=&quot;get-info&quot;&gt;GET&lt;/h3&gt;</span>
<span class="s">  {</span><span class="si">% i</span><span class="s">f request.GET %}</span>
<span class="s">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">      &lt;thead&gt;</span>
<span class="s">        &lt;tr&gt;</span>
<span class="s">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">        &lt;/tr&gt;</span>
<span class="s">      &lt;/thead&gt;</span>
<span class="s">      &lt;tbody&gt;</span>
<span class="s">        {</span><span class="si">% f</span><span class="s">or var in request.GET.items %}</span>
<span class="s">          &lt;tr&gt;</span>
<span class="s">            &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">          &lt;/tr&gt;</span>
<span class="s">        {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">      &lt;/tbody&gt;</span>
<span class="s">    &lt;/table&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">    &lt;p&gt;No GET data&lt;/p&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndif %}</span>

<span class="s">  &lt;h3 id=&quot;post-info&quot;&gt;POST&lt;/h3&gt;</span>
<span class="s">  {</span><span class="si">% i</span><span class="s">f filtered_POST %}</span>
<span class="s">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">      &lt;thead&gt;</span>
<span class="s">        &lt;tr&gt;</span>
<span class="s">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">        &lt;/tr&gt;</span>
<span class="s">      &lt;/thead&gt;</span>
<span class="s">      &lt;tbody&gt;</span>
<span class="s">        {</span><span class="si">% f</span><span class="s">or var in filtered_POST.items %}</span>
<span class="s">          &lt;tr&gt;</span>
<span class="s">            &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">          &lt;/tr&gt;</span>
<span class="s">        {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">      &lt;/tbody&gt;</span>
<span class="s">    &lt;/table&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">    &lt;p&gt;No POST data&lt;/p&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">  &lt;h3 id=&quot;files-info&quot;&gt;FILES&lt;/h3&gt;</span>
<span class="s">  {</span><span class="si">% i</span><span class="s">f request.FILES %}</span>
<span class="s">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">        &lt;thead&gt;</span>
<span class="s">            &lt;tr&gt;</span>
<span class="s">                &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">                &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">            &lt;/tr&gt;</span>
<span class="s">        &lt;/thead&gt;</span>
<span class="s">        &lt;tbody&gt;</span>
<span class="s">            {</span><span class="si">% f</span><span class="s">or var in request.FILES.items %}</span>
<span class="s">                &lt;tr&gt;</span>
<span class="s">                    &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">                    &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">                &lt;/tr&gt;</span>
<span class="s">            {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">        &lt;/tbody&gt;</span>
<span class="s">    &lt;/table&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">    &lt;p&gt;No FILES data&lt;/p&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndif %}</span>


<span class="s">  &lt;h3 id=&quot;cookie-info&quot;&gt;COOKIES&lt;/h3&gt;</span>
<span class="s">  {</span><span class="si">% i</span><span class="s">f request.COOKIES %}</span>
<span class="s">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">      &lt;thead&gt;</span>
<span class="s">        &lt;tr&gt;</span>
<span class="s">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">        &lt;/tr&gt;</span>
<span class="s">      &lt;/thead&gt;</span>
<span class="s">      &lt;tbody&gt;</span>
<span class="s">        {</span><span class="si">% f</span><span class="s">or var in request.COOKIES.items %}</span>
<span class="s">          &lt;tr&gt;</span>
<span class="s">            &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">          &lt;/tr&gt;</span>
<span class="s">        {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">      &lt;/tbody&gt;</span>
<span class="s">    &lt;/table&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">    &lt;p&gt;No cookie data&lt;/p&gt;</span>
<span class="s">  {</span><span class="si">% e</span><span class="s">ndif %}</span>

<span class="s">  &lt;h3 id=&quot;meta-info&quot;&gt;META&lt;/h3&gt;</span>
<span class="s">  &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">    &lt;thead&gt;</span>
<span class="s">      &lt;tr&gt;</span>
<span class="s">        &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s">        &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">      &lt;/tr&gt;</span>
<span class="s">    &lt;/thead&gt;</span>
<span class="s">    &lt;tbody&gt;</span>
<span class="s">      {</span><span class="si">% f</span><span class="s">or var in request.META.items|dictsort:&quot;0&quot; %}</span>
<span class="s">        &lt;tr&gt;</span>
<span class="s">          &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">          &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">        &lt;/tr&gt;</span>
<span class="s">      {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">    &lt;/tbody&gt;</span>
<span class="s">  &lt;/table&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">  &lt;p&gt;Request data not supplied&lt;/p&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>

<span class="s">  &lt;h3 id=&quot;settings-info&quot;&gt;Settings&lt;/h3&gt;</span>
<span class="s">  &lt;h4&gt;Using settings module &lt;code&gt;{{ settings.SETTINGS_MODULE }}&lt;/code&gt;&lt;/h4&gt;</span>
<span class="s">  &lt;table class=&quot;req&quot;&gt;</span>
<span class="s">    &lt;thead&gt;</span>
<span class="s">      &lt;tr&gt;</span>
<span class="s">        &lt;th&gt;Setting&lt;/th&gt;</span>
<span class="s">        &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s">      &lt;/tr&gt;</span>
<span class="s">    &lt;/thead&gt;</span>
<span class="s">    &lt;tbody&gt;</span>
<span class="s">      {</span><span class="si">% f</span><span class="s">or var in settings.items|dictsort:&quot;0&quot; %}</span>
<span class="s">        &lt;tr&gt;</span>
<span class="s">          &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="s">          &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s">        &lt;/tr&gt;</span>
<span class="s">      {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">    &lt;/tbody&gt;</span>
<span class="s">  &lt;/table&gt;</span>

<span class="s">&lt;/div&gt;</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f not is_email %}</span>
<span class="s">  &lt;div id=&quot;explanation&quot;&gt;</span>
<span class="s">    &lt;p&gt;</span>
<span class="s">      You&#39;re seeing this error because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in your</span>
<span class="s">      Django settings file. Change that to &lt;code&gt;False&lt;/code&gt;, and Django will</span>
<span class="s">      display a standard 500 page.</span>
<span class="s">    &lt;/p&gt;</span>
<span class="s">  &lt;/div&gt;</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">&lt;/body&gt;</span>
<span class="s">&lt;/html&gt;</span>
<span class="s">&quot;&quot;&quot;</span>

<span class="n">TECHNICAL_500_TEXT_TEMPLATE</span> <span class="o">=</span> <span class="s">&quot;&quot;&quot;{</span><span class="si">% lo</span><span class="s">ad firstof from future %}{</span><span class="si">% f</span><span class="s">irstof exception_type &#39;Report&#39; %}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% f</span><span class="s">irstof exception_value &#39;No exception message supplied&#39; %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f request %}</span>
<span class="s">Request Method: {{ request.META.REQUEST_METHOD }}</span>
<span class="s">Request URL: {{ request.build_absolute_uri }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">Django Version: {{ django_version_info }}</span>
<span class="s">Python Executable: {{ sys_executable }}</span>
<span class="s">Python Version: {{ sys_version_info }}</span>
<span class="s">Python Path: {{ sys_path }}</span>
<span class="s">Server time: {{server_time|date:&quot;r&quot;}}</span>
<span class="s">Installed Applications:</span>
<span class="s">{{ settings.INSTALLED_APPS|pprint }}</span>
<span class="s">Installed Middleware:</span>
<span class="s">{{ settings.MIDDLEWARE_CLASSES|pprint }}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f template_does_not_exist %}Template loader Error:</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f loader_debug_info %}Django tried loading these templates, in this order:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or loader in loader_debug_info %}Using loader {{ loader.loader }}:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or t in loader.templates %}{{ t.name }} ({{ t.status }})</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndfor %}{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}Django couldn&#39;t find any templates because your TEMPLATE_LOADERS setting is empty!</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">f template_info %}</span>
<span class="s">Template error:</span>
<span class="s">In template {{ template_info.name }}, error at line {{ template_info.line }}</span>
<span class="s">   {{ template_info.message }}{</span><span class="si">% f</span><span class="s">or source_line in template_info.source_lines %}{</span><span class="si">% i</span><span class="s">fequal source_line.0 template_info.line %}</span>
<span class="s">   {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">   {{ source_line.0 }} : {{ source_line.1 }}</span>
<span class="s">   {</span><span class="si">% e</span><span class="s">ndifequal %}{</span><span class="si">% e</span><span class="s">ndfor %}{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% i</span><span class="s">f frames %}</span>
<span class="s">Traceback:</span>
<span class="s">{</span><span class="si">% f</span><span class="s">or frame in frames %}File &quot;{{ frame.filename }}&quot; in {{ frame.function }}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f frame.context_line %}  {{ frame.lineno }}. {{ frame.context_line }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f exception_type %}Exception Type: {{ exception_type }}{</span><span class="si">% i</span><span class="s">f request %} at {{ request.path_info }}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f exception_value %}Exception Value: {{ exception_value }}{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% e</span><span class="s">ndif %}{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">{</span><span class="si">% i</span><span class="s">f request %}Request information:</span>
<span class="s">GET:{</span><span class="si">% f</span><span class="s">or k, v in request.GET.items %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">mpty %} No GET data{</span><span class="si">% e</span><span class="s">ndfor %}</span>

<span class="s">POST:{</span><span class="si">% f</span><span class="s">or k, v in filtered_POST.items %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">mpty %} No POST data{</span><span class="si">% e</span><span class="s">ndfor %}</span>

<span class="s">FILES:{</span><span class="si">% f</span><span class="s">or k, v in request.FILES.items %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">mpty %} No FILES data{</span><span class="si">% e</span><span class="s">ndfor %}</span>

<span class="s">COOKIES:{</span><span class="si">% f</span><span class="s">or k, v in request.COOKIES.items %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">mpty %} No cookie data{</span><span class="si">% e</span><span class="s">ndfor %}</span>

<span class="s">META:{</span><span class="si">% f</span><span class="s">or k, v in request.META.items|dictsort:&quot;0&quot; %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">{</span><span class="si">% e</span><span class="s">lse %}Request data not supplied</span>
<span class="s">{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">Settings:</span>
<span class="s">Using settings module {{ settings.SETTINGS_MODULE }}{</span><span class="si">% f</span><span class="s">or k, v in settings.items|dictsort:&quot;0&quot; %}</span>
<span class="s">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s">ndfor %}</span>

<span class="s">You&#39;re seeing this error because you have DEBUG = True in your</span>
<span class="s">Django settings file. Change that to False, and Django will</span>
<span class="s">display a standard 500 page.</span>
<span class="s">&quot;&quot;&quot;</span>

<span class="n">TECHNICAL_404_TEMPLATE</span> <span class="o">=</span> <span class="s">&quot;&quot;&quot;</span>
<span class="s">&lt;!DOCTYPE html&gt;</span>
<span class="s">&lt;html lang=&quot;en&quot;&gt;</span>
<span class="s">&lt;head&gt;</span>
<span class="s">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s">  &lt;title&gt;Page not found at {{ request.path_info|escape }}&lt;/title&gt;</span>
<span class="s">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;</span>
<span class="s">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="s">    html * { padding:0; margin:0; }</span>
<span class="s">    body * { padding:10px 20px; }</span>
<span class="s">    body * * { padding:0; }</span>
<span class="s">    body { font:small sans-serif; background:#eee; }</span>
<span class="s">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="s">    h1 { font-weight:normal; margin-bottom:.4em; }</span>
<span class="s">    h1 span { font-size:60%; color:#666; font-weight:normal; }</span>
<span class="s">    table { border:none; border-collapse: collapse; width:100%; }</span>
<span class="s">    td, th { vertical-align:top; padding:2px 3px; }</span>
<span class="s">    th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="s">    #info { background:#f6f6f6; }</span>
<span class="s">    #info ol { margin: 0.5em 4em; }</span>
<span class="s">    #info ol li { font-family: monospace; }</span>
<span class="s">    #summary { background: #ffc; }</span>
<span class="s">    #explanation { background:#eee; border-bottom: 0px none; }</span>
<span class="s">  &lt;/style&gt;</span>
<span class="s">&lt;/head&gt;</span>
<span class="s">&lt;body&gt;</span>
<span class="s">  &lt;div id=&quot;summary&quot;&gt;</span>
<span class="s">    &lt;h1&gt;Page not found &lt;span&gt;(404)&lt;/span&gt;&lt;/h1&gt;</span>
<span class="s">    &lt;table class=&quot;meta&quot;&gt;</span>
<span class="s">      &lt;tr&gt;</span>
<span class="s">        &lt;th&gt;Request Method:&lt;/th&gt;</span>
<span class="s">        &lt;td&gt;{{ request.META.REQUEST_METHOD }}&lt;/td&gt;</span>
<span class="s">      &lt;/tr&gt;</span>
<span class="s">      &lt;tr&gt;</span>
<span class="s">        &lt;th&gt;Request URL:&lt;/th&gt;</span>
<span class="s">      &lt;td&gt;{{ request.build_absolute_uri|escape }}&lt;/td&gt;</span>
<span class="s">      &lt;/tr&gt;</span>
<span class="s">    &lt;/table&gt;</span>
<span class="s">  &lt;/div&gt;</span>
<span class="s">  &lt;div id=&quot;info&quot;&gt;</span>
<span class="s">    {</span><span class="si">% i</span><span class="s">f urlpatterns %}</span>
<span class="s">      &lt;p&gt;</span>
<span class="s">      Using the URLconf defined in &lt;code&gt;{{ urlconf }}&lt;/code&gt;,</span>
<span class="s">      Django tried these URL patterns, in this order:</span>
<span class="s">      &lt;/p&gt;</span>
<span class="s">      &lt;ol&gt;</span>
<span class="s">        {</span><span class="si">% f</span><span class="s">or pattern in urlpatterns %}</span>
<span class="s">          &lt;li&gt;</span>
<span class="s">            {</span><span class="si">% f</span><span class="s">or pat in pattern %}</span>
<span class="s">                {{ pat.regex.pattern }}</span>
<span class="s">                {</span><span class="si">% i</span><span class="s">f forloop.last and pat.name %}[name=&#39;{{ pat.name }}&#39;]{</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">            {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">          &lt;/li&gt;</span>
<span class="s">        {</span><span class="si">% e</span><span class="s">ndfor %}</span>
<span class="s">      &lt;/ol&gt;</span>
<span class="s">      &lt;p&gt;The current URL, &lt;code&gt;{{ request_path|escape }}&lt;/code&gt;, didn&#39;t match any of these.&lt;/p&gt;</span>
<span class="s">    {</span><span class="si">% e</span><span class="s">lse %}</span>
<span class="s">      &lt;p&gt;{{ reason }}&lt;/p&gt;</span>
<span class="s">    {</span><span class="si">% e</span><span class="s">ndif %}</span>
<span class="s">  &lt;/div&gt;</span>

<span class="s">  &lt;div id=&quot;explanation&quot;&gt;</span>
<span class="s">    &lt;p&gt;</span>
<span class="s">      You&#39;re seeing this error because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in</span>
<span class="s">      your Django settings file. Change that to &lt;code&gt;False&lt;/code&gt;, and Django</span>
<span class="s">      will display a standard 404 page.</span>
<span class="s">    &lt;/p&gt;</span>
<span class="s">  &lt;/div&gt;</span>
<span class="s">&lt;/body&gt;</span>
<span class="s">&lt;/html&gt;</span>
<span class="s">&quot;&quot;&quot;</span>

<span class="n">DEFAULT_URLCONF_TEMPLATE</span> <span class="o">=</span> <span class="s">&quot;&quot;&quot;</span>
<span class="s">&lt;!DOCTYPE html&gt;</span>
<span class="s">&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;</span>
<span class="s">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;&lt;title&gt;Welcome to Django&lt;/title&gt;</span>
<span class="s">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="s">    html * { padding:0; margin:0; }</span>
<span class="s">    body * { padding:10px 20px; }</span>
<span class="s">    body * * { padding:0; }</span>
<span class="s">    body { font:small sans-serif; }</span>
<span class="s">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="s">    h1 { font-weight:normal; }</span>
<span class="s">    h2 { margin-bottom:.8em; }</span>
<span class="s">    h2 span { font-size:80%; color:#666; font-weight:normal; }</span>
<span class="s">    h3 { margin:1em 0 .5em 0; }</span>
<span class="s">    h4 { margin:0 0 .5em 0; font-weight: normal; }</span>
<span class="s">    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }</span>
<span class="s">    tbody td, tbody th { vertical-align:top; padding:2px 3px; }</span>
<span class="s">    thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }</span>
<span class="s">    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="s">    #summary { background: #e0ebff; }</span>
<span class="s">    #summary h2 { font-weight: normal; color: #666; }</span>
<span class="s">    #explanation { background:#eee; }</span>
<span class="s">    #instructions { background:#f6f6f6; }</span>
<span class="s">    #summary table { border:none; background:transparent; }</span>
<span class="s">  &lt;/style&gt;</span>
<span class="s">&lt;/head&gt;</span>

<span class="s">&lt;body&gt;</span>
<span class="s">&lt;div id=&quot;summary&quot;&gt;</span>
<span class="s">  &lt;h1&gt;It worked!&lt;/h1&gt;</span>
<span class="s">  &lt;h2&gt;Congratulations on your first Django-powered page.&lt;/h2&gt;</span>
<span class="s">&lt;/div&gt;</span>

<span class="s">&lt;div id=&quot;instructions&quot;&gt;</span>
<span class="s">  &lt;p&gt;</span>
<span class="s">    Of course, you haven&#39;t actually done any work yet.</span>
<span class="s">    Next, start your first app by running &lt;code&gt;python manage.py startapp [app_label]&lt;/code&gt;.</span>
<span class="s">  &lt;/p&gt;</span>
<span class="s">&lt;/div&gt;</span>

<span class="s">&lt;div id=&quot;explanation&quot;&gt;</span>
<span class="s">  &lt;p&gt;</span>
<span class="s">    You&#39;re seeing this message because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in your</span>
<span class="s">    Django settings file and you haven&#39;t configured any URLs. Get to work!</span>
<span class="s">  &lt;/p&gt;</span>
<span class="s">&lt;/div&gt;</span>
<span class="s">&lt;/body&gt;&lt;/html&gt;</span>
<span class="s">&quot;&quot;&quot;</span>
</pre></div>

          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3>Browse</h3>
  <ul>
    
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../../index.html">Django 1.7.8.dev20150401230226 documentation</a>
        
          <ul><li><a href="../../index.html">Module code</a>
        
          <ul><li><a href="../../django.html">django</a>
        
          <ul><li><a href="../views.html">django.views</a>
        
        <ul><li>django.views.debug</li></ul>
        </li></ul></li></ul></li></ul>
      </li>
  </ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Apr 02, 2015</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    <a href="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>